// version 2.0
if (typeof vmmaplayer !== 'undefined' && vmmaplayer.videoUrl) {

	//Read a page's GET URL variables and return them as an associative array.
	var getUrlParams = function() {
	    var vars = [], hash;
	    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
	    var i = 0;
	    for(i = 0; i < hashes.length; i++) {
	        hash = hashes[i].split('=');
	        vars.push(hash[0]);
	        vars[hash[0]] = decodeURIComponent(hash[1]);
	    }
	    return vars;
	};

	vmmaplayer.width = vmmaplayer.width || 400;
	vmmaplayer.height = vmmaplayer.height || 225;
	var src = 'http://jim.be/vmmaplayer/embed?videoUrl='+encodeURIComponent(vmmaplayer.videoUrl);
	if (vmmaplayer.width){src+="&amp;width="+encodeURIComponent(vmmaplayer.width);}
	if (vmmaplayer.height){src+="&amp;height="+encodeURIComponent(vmmaplayer.height);}
	if (vmmaplayer.imageUrl){src+="&amp;imageUrl="+encodeURIComponent(vmmaplayer.imageUrl);}
	if (vmmaplayer.title){src+="&amp;title="+encodeURIComponent(vmmaplayer.title);}
	if (vmmaplayer.url){src+="&amp;url="+encodeURIComponent(vmmaplayer.url);}
	if (vmmaplayer.program){src+="&amp;program="+encodeURIComponent(vmmaplayer.program);}
	if (vmmaplayer.iWatchUrl){src+="&amp;iWatchUrl="+encodeURIComponent(vmmaplayer.iWatchUrl);}
	if (vmmaplayer.showEmbed != null){src+="&amp;showEmbed="+encodeURIComponent(vmmaplayer.showEmbed);}
	if (vmmaplayer.subsiteUrl){
		src+="&amp;subsiteUrl="+encodeURIComponent(vmmaplayer.subsiteUrl);
	} else if (vmmaplayer.url) {
		src+="&amp;subsiteUrl="+encodeURIComponent(vmmaplayer.url);
	}
	if (vmmaplayer.relatedVideosFeedUrl){src+="&amp;relatedVideosFeedUrl="+encodeURIComponent(vmmaplayer.relatedVideosFeedUrl);}
	if (vmmaplayer.zoneId){src+="&amp;zoneId="+encodeURIComponent(vmmaplayer.zoneId);} // old parameter, you should use vmmaplayer.adZone
	if (vmmaplayer.adZone){src+="&amp;adZone="+encodeURIComponent(vmmaplayer.adZone);}

	var urlParams = getUrlParams();
	if (urlParams && urlParams['adops'] === 'player') {
		src+="&amp;adops=player";
	}

	document.write('<iframe src="'+src+'" width="'+vmmaplayer.width+'" height="'+vmmaplayer.height+'" scrolling="no" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>');
}